//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package org.jim.core.packets;

import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import java.util.List;
import org.apache.commons.collections4.CollectionUtils;

public class Group extends Message {
	private static final long serialVersionUID = -3817755433171220952L;
	private String groupId;
	private String name;
	private String avatar;
	private Integer online;
	private List<User> users;
	private List<String> userIds;
	private String owner;

	public String getOwner() {
		return this.owner;
	}

	public void setOwner(String owner) {
		this.owner = owner;
	}

	private Group() {
	}

	private Group(String groupId, String name, String avatar, Integer online, List<User> users, JSONObject extras) {
		this.groupId = groupId;
		this.name = name;
		this.avatar = avatar;
		this.online = online;
		this.users = users;
		this.extras = extras;
	}

	public static Builder newBuilder() {
		return new Builder();
	}

	public String getGroupId() {
		return this.groupId;
	}

	public void setGroupId(String groupId) {
		this.groupId = groupId;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getAvatar() {
		return this.avatar;
	}

	public void setAvatar(String avatar) {
		this.avatar = avatar;
	}

	public Integer getOnline() {
		return this.online;
	}

	public void setOnline(Integer online) {
		this.online = online;
	}

	public List<User> getUsers() {
		return this.users;
	}

	public void setUsers(List<User> users) {
		this.users = users;
	}

	public List<String> getUserIds() {
		return this.userIds;
	}

	public void setUserIds(List<String> userIds) {
		this.userIds = userIds;
	}

	public Group clone() {
		Group group = newBuilder().build();
		BeanUtil.copyProperties(this, group, new String[]{"users"});
		return group;
	}

	public static class Builder extends Message.Builder<Group, Builder> {
		private String groupId;
		private String name;
		private String avatar;
		private Integer online;
		private List<User> users = null;

		public Builder() {
		}

		public Builder groupId(String groupId) {
			this.groupId = groupId;
			return this;
		}

		public Builder name(String name) {
			this.name = name;
			return this;
		}

		public Builder avatar(String avatar) {
			this.avatar = avatar;
			return this;
		}

		public Builder setChatType(Integer online) {
			this.online = online;
			return this;
		}

		public Builder addUser(User user) {
			if (CollectionUtils.isEmpty(this.users)) {
				this.users = Lists.newArrayList();
			}

			this.users.add(user);
			return this;
		}

		protected Builder getThis() {
			return this;
		}

		public Group build() {
			return new Group(this.groupId, this.name, this.avatar, this.online, this.users, this.extras);
		}
	}
}
